/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package it.polimi.games.epkb.entityClasses;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author plebani
 */
@Entity
@Table(name = "stored_values")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "StoredValues.findAll", query = "SELECT s FROM StoredValues s"),
    @NamedQuery(name = "StoredValues.findById", query = "SELECT s FROM StoredValues s WHERE s.id = :id"),
    @NamedQuery(name = "StoredValues.findByDefinitionTime", query = "SELECT s FROM StoredValues s WHERE s.definitionTime = :definitionTime"),
    @NamedQuery(name = "StoredValues.findByComputedValue", query = "SELECT s FROM StoredValues s WHERE s.computedValue = :computedValue"),
    @NamedQuery(name = "StoredValues.findByContextID", query = "SELECT s FROM StoredValues s WHERE s.contextID = :contextID"),
    @NamedQuery(name = "StoredValues.findByRed", query = "SELECT s FROM StoredValues s WHERE s.red = :red"),
    @NamedQuery(name = "StoredValues.findByYellow", query = "SELECT s FROM StoredValues s WHERE s.yellow = :yellow")})
public class StoredValues implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    //@GeneratedValue(strategy = GenerationType.IDENTITY)
    @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="EMP_SEQ")
    @SequenceGenerator(name="EMP_SEQ", sequenceName="EMP_SEQ", allocationSize=100)
    @Basic(optional = false)
    @Column(name = "ID")
    private Long id;
    @Basic(optional = false)
    @Column(name = "DefinitionTime")
    @Temporal(TemporalType.TIMESTAMP)
    private Date definitionTime;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "ComputedValue")
    private BigDecimal computedValue;
    @Column(name = "ContextID")
    private Integer contextID;
    @Column(name = "Red")
    private Boolean red;
    @Column(name = "Yellow")
    private Boolean yellow;
    @JoinColumn(name = "Id_GPI_KPI", referencedColumnName = "ID")
    @ManyToOne(optional = false)
    private GpiKpi idGPIKPI;
    @JoinColumn(name = "Id_Component", referencedColumnName = "ID")
    @ManyToOne(optional = false)
    private Component idComponent;

    public StoredValues() {
    }

    public StoredValues(Long id) {
        this.id = id;
    }

    public StoredValues(Long id, Date definitionTime) {
        this.id = id;
        this.definitionTime = definitionTime;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Date getDefinitionTime() {
        return definitionTime;
    }

    public void setDefinitionTime(Date definitionTime) {
        this.definitionTime = definitionTime;
    }

    public BigDecimal getComputedValue() {
        return computedValue;
    }

    public void setComputedValue(BigDecimal computedValue) {
        this.computedValue = computedValue;
    }

    public Integer getContextID() {
        return contextID;
    }

    public void setContextID(Integer contextID) {
        this.contextID = contextID;
    }

    public Boolean getRed() {
        return red;
    }

    public void setRed(Boolean red) {
        this.red = red;
    }

    public Boolean getYellow() {
        return yellow;
    }

    public void setYellow(Boolean yellow) {
        this.yellow = yellow;
    }

    public GpiKpi getIdGPIKPI() {
        return idGPIKPI;
    }

    public void setIdGPIKPI(GpiKpi idGPIKPI) {
        this.idGPIKPI = idGPIKPI;
    }

    public Component getIdComponent() {
        return idComponent;
    }

    public void setIdComponent(Component idComponent) {
        this.idComponent = idComponent;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof StoredValues)) {
            return false;
        }
        StoredValues other = (StoredValues) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "it.polimi.games.epkb.entityClasses.StoredValues[ id=" + id + " ]";
    }
    
}
